{"ast":null,"code":"import canUseDom from './canUseDom';\nimport contains from './contains';\nvar APPEND_ORDER = 'data-rc-order';\nvar MARK_KEY = \"rc-util-key\";\nvar containerCache = new Map();\nfunction getMark() {\n  var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},\n    mark = _ref.mark;\n  if (mark) {\n    return mark.startsWith('data-') ? mark : \"data-\".concat(mark);\n  }\n  return MARK_KEY;\n}\nfunction getContainer(option) {\n  if (option.attachTo) {\n    return option.attachTo;\n  }\n  var head = document.querySelector('head');\n  return head || document.body;\n}\nfunction getOrder(prepend) {\n  if (prepend === 'queue') {\n    return 'prependQueue';\n  }\n  return prepend ? 'prepend' : 'append';\n}\n/**\n * Find style which inject by rc-util\n */\nfunction findStyles(container) {\n  return Array.from((containerCache.get(container) || container).children).filter(function (node) {\n    return node.tagName === 'STYLE';\n  });\n}\nexport function injectCSS(css) {\n  var option = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n  if (!canUseDom()) {\n    return null;\n  }\n  var csp = option.csp,\n    prepend = option.prepend;\n  var styleNode = document.createElement('style');\n  styleNode.setAttribute(APPEND_ORDER, getOrder(prepend));\n  if (csp === null || csp === void 0 ? void 0 : csp.nonce) {\n    styleNode.nonce = csp === null || csp === void 0 ? void 0 : csp.nonce;\n  }\n  styleNode.innerHTML = css;\n  var container = getContainer(option);\n  var firstChild = container.firstChild;\n  if (prepend) {\n    // If is queue `prepend`, it will prepend first style and then append rest style\n    if (prepend === 'queue') {\n      var existStyle = findStyles(container).filter(function (node) {\n        return ['prepend', 'prependQueue'].includes(node.getAttribute(APPEND_ORDER));\n      });\n      if (existStyle.length) {\n        container.insertBefore(styleNode, existStyle[existStyle.length - 1].nextSibling);\n        return styleNode;\n      }\n    }\n    // Use `insertBefore` as `prepend`\n    container.insertBefore(styleNode, firstChild);\n  } else {\n    container.appendChild(styleNode);\n  }\n  return styleNode;\n}\nfunction findExistNode(key) {\n  var option = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n  var container = getContainer(option);\n  return findStyles(container).find(function (node) {\n    return node.getAttribute(getMark(option)) === key;\n  });\n}\nexport function removeCSS(key) {\n  var option = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n  var existNode = findExistNode(key, option);\n  if (existNode) {\n    var container = getContainer(option);\n    container.removeChild(existNode);\n  }\n}\n/**\n * qiankun will inject `appendChild` to insert into other\n */\nfunction syncRealContainer(container, option) {\n  var cachedRealContainer = containerCache.get(container);\n  // Find real container when not cached or cached container removed\n  if (!cachedRealContainer || !contains(document, cachedRealContainer)) {\n    var placeholderStyle = injectCSS('', option);\n    var parentNode = placeholderStyle.parentNode;\n    containerCache.set(container, parentNode);\n    container.removeChild(placeholderStyle);\n  }\n}\n/**\n * manually clear container cache to avoid global cache in unit testes\n */\nexport function clearContainerCache() {\n  containerCache.clear();\n}\nexport function updateCSS(css, key) {\n  var option = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};\n  var container = getContainer(option);\n  // Sync real parent\n  syncRealContainer(container, option);\n  var existNode = findExistNode(key, option);\n  if (existNode) {\n    var _option$csp, _option$csp2;\n    if (((_option$csp = option.csp) === null || _option$csp === void 0 ? void 0 : _option$csp.nonce) && existNode.nonce !== ((_option$csp2 = option.csp) === null || _option$csp2 === void 0 ? void 0 : _option$csp2.nonce)) {\n      var _option$csp3;\n      existNode.nonce = (_option$csp3 = option.csp) === null || _option$csp3 === void 0 ? void 0 : _option$csp3.nonce;\n    }\n    if (existNode.innerHTML !== css) {\n      existNode.innerHTML = css;\n    }\n    return existNode;\n  }\n  var newNode = injectCSS(css, option);\n  newNode.setAttribute(getMark(option), key);\n  return newNode;\n}","map":{"version":3,"names":["canUseDom","contains","APPEND_ORDER","MARK_KEY","containerCache","Map","getMark","_ref","arguments","length","undefined","mark","startsWith","concat","getContainer","option","attachTo","head","document","querySelector","body","getOrder","prepend","findStyles","container","Array","from","get","children","filter","node","tagName","injectCSS","css","csp","styleNode","createElement","setAttribute","nonce","innerHTML","firstChild","existStyle","includes","getAttribute","insertBefore","nextSibling","appendChild","findExistNode","key","find","removeCSS","existNode","removeChild","syncRealContainer","cachedRealContainer","placeholderStyle","parentNode","set","clearContainerCache","clear","updateCSS","_option$csp","_option$csp2","_option$csp3","newNode"],"sources":["/data/messenger.client/node_modules/rc-util/es/Dom/dynamicCSS.js"],"sourcesContent":["import canUseDom from './canUseDom';\nimport contains from './contains';\nvar APPEND_ORDER = 'data-rc-order';\nvar MARK_KEY = \"rc-util-key\";\nvar containerCache = new Map();\nfunction getMark() {\n  var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},\n    mark = _ref.mark;\n  if (mark) {\n    return mark.startsWith('data-') ? mark : \"data-\".concat(mark);\n  }\n  return MARK_KEY;\n}\nfunction getContainer(option) {\n  if (option.attachTo) {\n    return option.attachTo;\n  }\n  var head = document.querySelector('head');\n  return head || document.body;\n}\nfunction getOrder(prepend) {\n  if (prepend === 'queue') {\n    return 'prependQueue';\n  }\n  return prepend ? 'prepend' : 'append';\n}\n/**\n * Find style which inject by rc-util\n */\nfunction findStyles(container) {\n  return Array.from((containerCache.get(container) || container).children).filter(function (node) {\n    return node.tagName === 'STYLE';\n  });\n}\nexport function injectCSS(css) {\n  var option = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n  if (!canUseDom()) {\n    return null;\n  }\n  var csp = option.csp,\n    prepend = option.prepend;\n  var styleNode = document.createElement('style');\n  styleNode.setAttribute(APPEND_ORDER, getOrder(prepend));\n  if (csp === null || csp === void 0 ? void 0 : csp.nonce) {\n    styleNode.nonce = csp === null || csp === void 0 ? void 0 : csp.nonce;\n  }\n  styleNode.innerHTML = css;\n  var container = getContainer(option);\n  var firstChild = container.firstChild;\n  if (prepend) {\n    // If is queue `prepend`, it will prepend first style and then append rest style\n    if (prepend === 'queue') {\n      var existStyle = findStyles(container).filter(function (node) {\n        return ['prepend', 'prependQueue'].includes(node.getAttribute(APPEND_ORDER));\n      });\n      if (existStyle.length) {\n        container.insertBefore(styleNode, existStyle[existStyle.length - 1].nextSibling);\n        return styleNode;\n      }\n    }\n    // Use `insertBefore` as `prepend`\n    container.insertBefore(styleNode, firstChild);\n  } else {\n    container.appendChild(styleNode);\n  }\n  return styleNode;\n}\nfunction findExistNode(key) {\n  var option = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n  var container = getContainer(option);\n  return findStyles(container).find(function (node) {\n    return node.getAttribute(getMark(option)) === key;\n  });\n}\nexport function removeCSS(key) {\n  var option = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n  var existNode = findExistNode(key, option);\n  if (existNode) {\n    var container = getContainer(option);\n    container.removeChild(existNode);\n  }\n}\n/**\n * qiankun will inject `appendChild` to insert into other\n */\nfunction syncRealContainer(container, option) {\n  var cachedRealContainer = containerCache.get(container);\n  // Find real container when not cached or cached container removed\n  if (!cachedRealContainer || !contains(document, cachedRealContainer)) {\n    var placeholderStyle = injectCSS('', option);\n    var parentNode = placeholderStyle.parentNode;\n    containerCache.set(container, parentNode);\n    container.removeChild(placeholderStyle);\n  }\n}\n/**\n * manually clear container cache to avoid global cache in unit testes\n */\nexport function clearContainerCache() {\n  containerCache.clear();\n}\nexport function updateCSS(css, key) {\n  var option = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};\n  var container = getContainer(option);\n  // Sync real parent\n  syncRealContainer(container, option);\n  var existNode = findExistNode(key, option);\n  if (existNode) {\n    var _option$csp, _option$csp2;\n    if (((_option$csp = option.csp) === null || _option$csp === void 0 ? void 0 : _option$csp.nonce) && existNode.nonce !== ((_option$csp2 = option.csp) === null || _option$csp2 === void 0 ? void 0 : _option$csp2.nonce)) {\n      var _option$csp3;\n      existNode.nonce = (_option$csp3 = option.csp) === null || _option$csp3 === void 0 ? void 0 : _option$csp3.nonce;\n    }\n    if (existNode.innerHTML !== css) {\n      existNode.innerHTML = css;\n    }\n    return existNode;\n  }\n  var newNode = injectCSS(css, option);\n  newNode.setAttribute(getMark(option), key);\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